package com.qujia.enums;

/**
 * 积分变更类型
 */
public enum ActionTypeEnum {
    EXCHANGE_GOODS("1", "兑换商品"),
    REFUEL("2", "加油"),
    CONSUMEPRESENT("3", "充值赠送"),
    REFUND("4", "退款"),
    MANUAL_ADDITION("5", "手动添加"),
    MANUAL_REDUCTION("6", "手动消减"),
    MANUAL_IMPORT("7", "导入");

    private String code;
    private String name;

    ActionTypeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static String getNameByCode(String code) {
        for (ActionTypeEnum type : ActionTypeEnum.values()) {
            if (type.getCode().equals(code)) {
                return type.getName();
            }
        }
        throw new IllegalStateException("enums.type.invalidcode#" + code + "#"
                + ActionTypeEnum.class.getName());
    }
}
